package com.cqgc.task;

import com.cqgc.mapper.OrderMapper;
import com.cqgc.pojo.entity.Order;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class OrderDeadLetterConsumer {

    @Autowired
    private OrderMapper orderMapper;

//    @RabbitListener(queues = "order_dead_letter_queue")
    public void processTimeoutOrder(String orderNumber) {

        log.info("订单超时，订单号：{}", orderNumber);
        // 查看订单状态
        Order order = orderMapper.findById(orderNumber);
        if (order != null && order.getStatus() == 1){
            // 修改订单状态
            order.setStatus(3);
            orderMapper.updateStatus(order);
        }
    }
}
